import { Button } from "antd";
import { useEffect, useState } from "react";

function Test() {
  const [count, setCount] = useState<number>(0);

  useEffect(() => {
    setTimeout(
      () =>
        setCount(prev => {
          console.log("prev的值", prev);
          return prev + 1;
        }),
      3000
    );
  }, []);

  return (
    <>
      <h2>测试Hooks-{count}</h2>
      <Button type="primary" onClick={() => setCount(prev => prev + 1)}>
        点我
      </Button>
    </>
  );
}

export default Test;
